
<!DOCTYPE HTML>
<html>
<head>
    <title>login</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="__STATIC__/css/style.css" rel="stylesheet" type="text/css" media="all"/>
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/plugins/layui/layui.js"></script>
</head>
<body>
<div class="login">
    <h2>Acced Form</h2>
    <div class="login-top">
        <h1>登录</h1>
        <span id="spanMsg" style="text-align: center"></span>
        <form action="" method="post" class="layui-form">
            <input type="text" placeholder="请输入账号" id="username"  lay-verify=”required”>
            <input type="password" placeholder="请输入密码"  id="password" lay-verify=”required”>
            <div class="forgot">
                <button type="button" onclick="submitLogin()" lay-filter="formDemo">登录</button>
            </div>
        </form>
    </div>
    <div class="login-bottom">
        <h3></h3>
    </div>
</div>
<script>
    $(document).keyup(function(event){
        if(event.keyCode ==13){
            $("#submit").trigger(submitLogin());
        }
    });
   function submitLogin(){
       var  username=$('#username').val();
       var  password=$('#password').val();
       if(username ==""){
           return false;
       }
       if(password ==""){
           return false;
       }
       $.post('{:url("index/login")}',{username:username,password:password},function(data){
            if(data.token=='1'){
                $('#spanMsg').html(data.msg).css('color','red');
            }else{
                window.location.replace('{:url("questionnaire/index")}');
            }
       })
   }

</script>
</body>
</html>